<template>
	<view>
		<view class="fui-header fui-header-success">
<view class="fui-header-left" @click="result" ><text style="font-size: 32rpx"></text></view>
			<view class="title">订单详情</view>
		</view>
		<view class="status_bar"></view>
		<view class="fui-content navbar">		
			<view class="result-list nomargin">
				<view class="fui-list order-status">
					<view class="fui-list-inner">
						<view class="title">
							{{one.status}}                                                                            
						</view>
						<view class="text">订单金额(含运费): ¥ {{one.goodsprice}}<text></text></view>
					</view>
					<view class="fui-list-media">
						<text class="icon icon-money"></text>
					</view>
				</view>
			</view>
	
			<view class="fui-cell-group info-cell-group" style="table-layout:fixed;">
				<view class="fui-cell">
					<view class="fui-cell-label">订单编号:</view>
					<view class="fui-cell-info"></view>
					<view class="fui-cell-remark noremark black">{{one.ordersn}}</view>
				</view>
				<view class="fui-cell">
					<view class="fui-cell-label">订单状态:</view>
					<view class="fui-cell-info"></view>
					<view class="fui-cell-remark noremark">
						<text class="fui-label fui-label-danger round">
							{{one.status}}                                                    
						</text>
					</view>
				</view>
				<view class="fui-cell">
					<view class="fui-cell-label">支付状态:</view>
					<view class="fui-cell-info"></view>
					<view class="fui-cell-remark noremark">
						{{one.statusstr}}
					</view>
				</view>
				<!-- jack 20201218  -->
				<view class="fui-cell" v-if="one.verifycode">
					<view class="fui-cell-label">自提码:</view>
					<view class="fui-cell-info"></view>
					<view class="fui-cell-remark noremark">
						{{one.verifycode}}
					</view>
				</view>
				<view class="fui-cell" v-if="one.dispatchname">
					<view class="fui-cell-label">配送方式:</view>
					<view class="fui-cell-info"></view>
					<view class="fui-cell-remark noremark black">
						{{one.dispatchname}}                                  
					</view>
				</view>
			</view>
			
			<!-- 订单完成-发货信息 -->
			<view class="fui-cell-group" v-if="one.status=='待收货'">
				<view class="fui-cell">
					<view class="fui-cell-info"><text class="icon icon-gifts"></text> 发货信息 - <text class="text-danger">包裹A</text></view>
					<navigator class="fui-cell-remark" data-nocache="true" :url="'./express?express='+one.express+'&expresssn='+one.expresssn">查看物流</navigator>
				</view>
				
				<navigator v-for="(k, i) in one.goods" :key="index" class="fui-list" data-nocache="true" >
					
					<view class="fui-list-media">
						<image :src="one.goods[i].thumb" class="round small">
					</view>
					<view class="fui-list-inner">
						<view class="subtitle">{{ one.goods[i].title}}</view>
					</view>
					<view class="angle"></view>
				</navigator>
				
				<view class="fui-cell">
					<view class="fui-cell-label">快递公司</view>
					<view class="fui-cell-info">其他快递</view>
					<navigator class="fui-cell-remark" data-nocache="true" :url="'./changeexpress?id='+id">修改</navigator>
				</view>
				<view class="fui-cell">
					<view class="fui-cell-label">快递单号</view>
					<view class="fui-cell-info newline">{{one.expresssn}}</view>
				</view>
				<view class="fui-cell">
					<view class="fui-cell-label">发货时间</view>
					<view class="fui-cell-info">{{one.createtime}}</view>
				</view>
			</view>

			<template v-if="one.status!='待收货'&&one.status!=='待评价'">
				<view class="fui-cell-group" v-if="one.dispatchname!='自提'">
					<view class="fui-cell">
						<view class="fui-cell-info"><text class="icon icon-location"></text> 收件信息</view>									  
						<navigator class="fui-cell-remark text-success" data-nocache="true" :url="'./changeaddress?id='+id">修改</navigator>						
					</view>
				</view>
				<view class="fui-cell-group nomargin" v-if="one.addressdata">
					<view class="fui-cell">
						<view class="fui-cell-label gray">收件人: </view>
						<view class="fui-cell-info"></view>
						<view class="fui-cell-remark noremark black">{{one.addressdata.realname}}</view>
					</view>
					<view class="fui-cell">
						<view class="fui-cell-label gray">联系电话: </view>
						<view class="fui-cell-info"></view>
						<view class="fui-cell-remark noremark black">{{one.addressdata.mobile}}</view>
					</view>
					<view class="fui-cell">
						<view class="fui-cell-label gray">收货地址: </view>
						<view class="fui-cell-info"></view>
						<view class="fui-cell-remark noremark black">{{one.addressdata.address}}</view>
					</view>
				</view>			
				<view class="fui-cell-group">
					<view class="fui-cell">
						<view class="fui-cell-info"><text class="icon icon-card"></text> 会员信息</view>
					</view>
				</view>
			</template>	
			<view class="fui-list-group nomargin" v-if="one.member">
				<navigator class="fui-list" url="#" data-nocache="true">
					<view class="fui-list-media">
						<img  :src="one.member.avatar" class="round">
					</view>
					<view class="fui-list-inner">
						
						<view class="title">{{one.member.nickname}} <text>({{one.member.realname}})</text></view>
						<view class="subtitle">
							<view class="total half">手机号: {{one.member.mobile}}</view>
							<view class="total half">微信号: 未设置</view>
						</view>
					</view>
				</navigator>
			</view>
			<!-- 维权处理 -->
			<view class="fui-cell-group" v-if="one.status==4">
				<view class="fui-cell">
					<view class="fui-cell-info"><text class="icon icon-card"></text>维权处理</view>
				</view>
				<view class="fui-cell">
					<view class="fui-cell-label gray">处理方式</view>
					<view class="fui-cell-info">退款</view>
					
				</view>
				<view class="fui-cell">
					<view class="fui-cell-label gray">处理结果</view>
					<view class="fui-cell-info">
						<radio-group name="gender" @change="setBackValue">
							<label>
								<radio value="1" :checked="(BackValue==1)?true:false"/><text>驳回申请</text>
							</label>
							<label>
								<radio value="2" :checked="(BackValue==2)?true:false"/><text>同意退款</text>
							</label>
							<label>
								<radio value="3" :checked="(BackValue==3)?true:false"/><text>手动退款</text>
							</label>
						</radio-group>
					</view>
				</view>	
				<view class="fui-cell" v-if="BackValue==1">
					<view class="fui-cell-label auto gray">驳回原因</view>
					<view class="fui-cell-info"><input type="text" placeholder="请输入驳回原因" class="fui-input" value="" id="" ></view>
				</view>
				<view class="fui-cell" v-if="BackValue==2">
					<view class="fui-cell-label auto gray"></view>
					<view class="fui-cellinfo">
						微信支付方式：会返回到相应的的支付渠道(如零钱或银行卡）<br/>
						其他支付方式：会返回到微信钱包(需商户平台余额充足)<br/>
						如有余额抵扣：会返回金额到商城用户余额<br/>
						如有积分抵扣：会返回积分到商城用户积分<br/>
						手动退款：订单会完成退款处理，您用其他方式进行退款
					</view>
				</view>
				<view class="fui-cell" >
					<view class="fui-cell-label auto gray"></view>
					<view class="fui-cell-info">						
						<navigator class="btn btn-success btn-sm order-btn" >提交</navigator>
						<navigator class="btn btn-sm btn-default order-btn">取消</navigator>
					</view>
				</view>
			</view>		
			<!-- 订单商品明细 -->
			<view class="fui-cell-group">
				<view class="fui-cell">
					<view class="fui-cell-info"><text class="icon icon-gifts"></text> 订单商品</view>
					<view class="fui-cell-remark noremark"><text>(价格单位: 元)</text></view>
				</view>
			</view>
			<view class="fui-list-group goods-list-group nomargin" >
			
				<view v-for="(k, i) in one.goods"  class="fui-list goods-list check-param" data-action="diyform-goods-7383" @click="goodsUrl(k.id)">
					<navigator class="fui-list-media" :url="'jxshops.php?r=merchmanage.goods.edit&amp;id='+k.id">
						<!-- :src="k.thumb"-->
						<img  class="round" :src="k.thumb"/>
					</navigator>
					<view class="fui-list-inner">
						<view class="title">
							{{k.title}}
						</view>
						<view class="text goodstitle">规格:  {{k.optionname}}</view>
						<view class="subtitle">
							<view class="total half">单价/数量: {{k.orderprice}}x{{k.total}}</view>
							<view class="total half text-right">折扣前/后: {{k.orderprice}}/{{k.realprice}}</view>
						</view>
					</view>
				</view>
			</view>
			
			<!-- 订单价格小计 -->
			<view class="fui-cell-group">
				<view class="fui-cell">
					<view class="fui-cell-label gray">商品小计</view>
					<view class="fui-cell-info"></view>
					<view class="fui-cell-remark noremark black">￥{{one.goodsprice}}</view>
				</view>
				<view class="fui-cell">
					<view class="fui-cell-label gray">运费</view>
					<view class="fui-cell-info"></view>
					<view class="fui-cell-remark noremark black">￥{{one.olddispatchprice}}</view>
				</view>	
				<view class="fui-cell">
					<view class="fui-cell-label auto gray">实付费(含运费)</view>
					<view class="fui-cell-info"></view>
					<view class="fui-cell-remark noremark black">￥{{one.price}}</view>
				</view>
			</view>			
			<view class="fui-cell-group info-cell-group" style="table-layout:fixed;">
				<view class="fui-cell">
					<view class="fui-cell-label">下单时间:</view>
					<view class="fui-cell-info">{{one.createtime}}</view>
				</view>
				<view class="fui-cell">
					<view class="fui-cell-label">支付时间: </view>
					<view class="fui-cell-info">{{one.paytime}}</view>
				</view>
			</view>
	
			<view class="fui-cell-group">
				<view class="fui-cell">
					<view class="fui-cell-info"><text class="icon icon-group"></text> 分销商信息</view>
				</view>
			</view>
		
			<view class="fui-list-group nomargin">
				<navigator class="fui-list" url="#" data-nocache="true"   v-for="(key, index) in agents" :key="index">
					<view class="fui-list-media round">
						<image :src="agents[index].avatar" class="round">
						<view class="title">{{agents[index].realname}}</view>
					</view>
					<view class="fui-list-inner">
						<view class="title">
							<text class="total">{{agents[index].realname}}</text>
						</view>
						<view class="subtitle">
							<text class="total half">佣金: {{agents[index].commission}}元</text>
							<text class="total half">手机号: {{agents[index].mobile}}</text>
						</view>
					</view>
				</navigator>
				
			</view>						
			<view class="fui-title center">更多信息请至PC端查看</view>
		</view>
		<view class="status_bar"></view>
		<view class="fui-footer order-detail">
			<navigator class="btn btn-sm btn-default order-btn" data-action="remarksaler"  :url="'./remarks?id='+id">
				<text class="text-success iconfont icon-beizhu161129"></text> 备注
			</navigator>
			
			<navigator v-if="one.verifycode"  class="btn btn-success btn-sm order-btn" data-action="send"  @tap="deliver(id)">确认取货</navigator>
			<navigator v-else class="btn btn-success btn-sm order-btn" data-action="send"  :url="'../order/send?id='+id">确认发货</navigator>
			
		</view>
	
	</view>
</template>

<script>
var t = getApp().globalData,
	e = t.requirejs('core'),
	i = t.requirejs('foxui'),
	a = t.requirejs('jquery');
	export default {
		data() {
			return {
				one:{},
				//分销商
				agents:[],
				keyword:'',
				searchfield:'ordersn',
				index:0,
				id:'',
				show: false,
				transShow: false,
				modeClass: ['fade'],
				maskClass: {
					'position': 'fixed',
					'bottom': 0,
					'top': 0,
					'left': 0,
					'right': 0,
					'background-color': 'rgba(0, 0, 0, 0.4)'
				},
				transfromClass: {
					'position': 'fixed',
					'bottom': 0,
					'top': 0,
					'left': 0,
					'right': 0,
					'justify-content': 'center',
					'align-items': 'center',
					'background':'#f3f3f3',
					'z-index':'99'
				},
				BackValue:1
			}
		},
		onLoad(e){
			this.id=e.id
		},
		onShow(){
			this.init()
		},
		methods: {
			//确认取货吗
			deliver(id){
				// 少确定取货接口
				uni.showModal({
				    title: '提示',
				    content: '确认取货吗吗',
				    success: function (res) {
						  if (res.confirm) {
							  
							  
						  }
					}
				})
				
			},
			goodsUrl(id){
				let url=t.api+'&r=goods.detail&id='+id
				url=url.replace("jxshops_api.php","jxshops.php")　
				location.href=url
			},
			init(){
				let self=this
				e.get('merchmanage/order/detail',{id:this.id},function(e) {
					self.one=e.item
					self.agents=e.agents
					
					//发货时间戳转时间
					self.one.createtime=self.transformTime(self.one.createtime*1000)
					//支付戳转时间
					self.one.paytime=self.transformTime(self.one.paytime*1000)
				})
				
				//订单详情
				/*e.get('merchmanage.order.getlist', {}, function(t) {
					self.one=t.result
				});*/
				
			},
			 transformTime(timestamp) {
			        if (timestamp) {
			            var time = new Date(timestamp);
			            var y = time.getFullYear(); //getFullYear方法以四位数字返回年份
			            var M = time.getMonth() + 1; // getMonth方法从 Date 对象返回月份 (0 ~ 11)，返回结果需要手动加一
			            var d = time.getDate(); // getDate方法从 Date 对象返回一个月中的某一天 (1 ~ 31)
			            var h = time.getHours(); // getHours方法返回 Date 对象的小时 (0 ~ 23)
			            var m = time.getMinutes(); // getMinutes方法返回 Date 对象的分钟 (0 ~ 59)
			            var s = time.getSeconds(); // getSeconds方法返回 Date 对象的秒数 (0 ~ 59)
						if(d<=9){
							d='0'+d
						}
						if(m<=9){
							m='0'+m
						}
			            return y + '-' + M + '-' + d + ' ' + h + ':' + m + ':' + s;
			        } else {
			            return '';
			        }
			    },
			//搜索
			search(){
				
				
			},
			//返回上一页
			result(){
				uni.navigateTo({
				    url: './order'
				});
			},
			// 维权处理
			setBackValue(e){
				this.BackValue = e.target.value;
			}
		}
	}
</script>

<style>
.fui-list-media .round{
	width: 90rpx;
	height: 90rpx;
}
.result-list .icon{
	color: #fff;
	font-size: 80rpx;
}

.order-status .title{
	color: #fff;
	font-size: 34rpx;
	font-weight: bold;
}
.order-status .text{
	color: #fff;
	padding-top: 20rpx;
}
.fui-header .iconfont{
	color: #fff;
	font-size: 24rpx;
	padding: 0 20rpx;
}
.fui-label.round{
	border-radius: 10rpx;
	padding: 5rpx 10rpx;
}
.fui-list-inner .subtitle .total.half{
	width: 45%;
	display: inline-block;
}
.fui-list-inner .title{
	font-size: 28rpx;
}
.fui-cell-info .icon{
	padding-right: 10rpx;
}
.fui-list-media.round{
	border-radius: 12rpx;
	overflow: hidden;
}
.fui-footer{
	text-align: right;
}
.btn.btn-default{
	background: #f7f7f7 !important;
	border: 1px solid #dfdfdf;
	margin-left: 20rpx;
}
.btn.btn-default .iconfont{
	padding-right: 10rpx;
}
.fui-footer .btn{
	margin: 20rpx 10rpx;
}
.fui-list-media .title{
	font-size: 22rpx;
}
.uni-label-pointer{
	margin-right: 20rpx;
}

</style>
